package cn.test.action.user;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;


import cn.test.bean.User;
import cn.test.service.UserService;

import com.opensymphony.xwork2.ActionSupport;

public class UserSaveAction extends ActionSupport {
	private User user;
	private UserService userService;

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	@Override
	public String execute() throws Exception {
		this.userService.saveUser(user);
		return SUCCESS;
	}

	public void validate() {
		Map map=(Map)this.getFieldErrors();
		Set set=map.keySet();
		for(Iterator s=set.iterator();s.hasNext();){
			System.out.println(map.get(s.next()));
		}
		
	}

}
